package my.jwds.p26;

import java.util.Arrays;

public class RemoveDuplicates {

    public static void main(String[] args) {
        RemoveDuplicates o = new RemoveDuplicates();
        int [] nums = {};
        System.out.println(o.removeDuplicates(nums));
        System.out.println(Arrays.toString(nums));
    }

    public int removeDuplicates(int[] nums) {
        if (nums.length == 0)return 0;
        int index = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[index] != nums[i]){
                nums[++index] = nums[i];
            }
        }
        return index+1;
    }
}
